﻿#region Using

using System.Xml.Serialization;

using Common.Enums;

using GameCommon.Components;
using GameCommon.Converters;

using Microsoft.Xna.Framework;

#endregion

namespace Menu.XmlEntities
{
    public class XmlToolTip
    {
        private Color backgroundColor;

        public XmlToolTip()
        {
            this.Layer = 1;
        }

        [XmlAttribute("Id")]
        public string Id { get; set; }

        [XmlAttribute("Layer")]
        public int Layer { get; set; }

        [XmlAttribute("Opacity")]
        public int Opacity { get; set; }

        [XmlAttribute("Size")]
        public FontSizeEnum FontSize { get; set; }

        [XmlAttribute("Font")]
        public FontEnum FontEnum { get; set; }

        [XmlAttribute("LineHeight")]
        public int LineHeight { get; set; }

        [XmlAttribute("Padding")]
        public int Padding { get; set; }

        [XmlText]
        public string Value { get; set; }

        [XmlAttribute("HorizontalAlignment")]
        public HorizontalAlignment HorizontalAlignment { get; set; }

        [XmlAttribute("VerticalAlignment")]
        public VerticalAlignment VerticalAlignment { get; set; }

        [XmlAttribute("BackgroundColor")]
        public string BackgroundColor
        {
            get
            {
                return this.backgroundColor.ToString();
            }

            set
            {
                this.backgroundColor = Converter.Color.Convert(value);
            }
        }

        public ToolTip GetComponent()
        {
            var comp = new ToolTip(this.Id);
            comp.Layer = this.Layer;
            comp.Padding = this.Padding;
            comp.Opacity = this.Opacity;
            comp.FontSize = this.FontSize;
            comp.FontEnum = this.FontEnum;
            comp.Value = this.Value.Trim();
            comp.LineHeight = this.LineHeight;
            comp.BackgroundColor = this.backgroundColor;
            comp.HorizontalAlignment = this.HorizontalAlignment;
            comp.VerticalAlignment = this.VerticalAlignment;

            comp.Settle();

            return comp;
        }
    }
}